package com.suep.data_analysis.repository;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.suep.data_analysis.model.AgentAttribute;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AgentAttributeRepository extends BaseMapper<AgentAttribute> {

    /**
     * 根据条件查询代理人属性列表
     */
    @Select("SELECT * FROM t_agent_attribute WHERE ${ew.SQLSegment}")
    @Results({
            @Result(property = "attrId", column = "attr_id"),
            @Result(property = "agentId", column = "agent_id"),
            @Result(property = "baseHp", column = "base_hp"),
            @Result(property = "baseAttack", column = "base_attack"),
            @Result(property = "baseDefense", column = "base_defense"),
            @Result(property = "impactPower", column = "impact_power"),
            @Result(property = "critRate", column = "crit_rate"),
            @Result(property = "critDamage", column = "crit_damage"),
            @Result(property = "penetrationRate", column = "penetration_rate"),
            @Result(property = "penetrationValue", column = "penetration_value"),
            @Result(property = "anomalyMastery", column = "anomaly_mastery"),
            @Result(property = "anomalyResistance", column = "anomaly_resistance"),
            @Result(property = "energyCapacity", column = "energy_capacity"),
            @Result(property = "energyRegenRate", column = "energy_regen_rate"),
            @Result(property = "talentBonus", column = "talent_bonus", typeHandler = com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "updateTime", column = "update_time")
    })
    List<AgentAttribute> selectAgentAttribute(@Param("ew") Wrapper<AgentAttribute> queryWrapper);

    /**
     * 根据代理人ID查询属性
     */
    @Select("SELECT * FROM t_agent_attribute WHERE agent_id = #{agentId}")
    @Results({
            @Result(property = "attrId", column = "attr_id"),
            @Result(property = "agentId", column = "agent_id"),
            @Result(property = "baseHp", column = "base_hp"),
            @Result(property = "baseAttack", column = "base_attack"),
            @Result(property = "baseDefense", column = "base_defense"),
            @Result(property = "impactPower", column = "impact_power"),
            @Result(property = "critRate", column = "crit_rate"),
            @Result(property = "critDamage", column = "crit_damage"),
            @Result(property = "penetrationRate", column = "penetration_rate"),
            @Result(property = "penetrationValue", column = "penetration_value"),
            @Result(property = "anomalyMastery", column = "anomaly_mastery"),
            @Result(property = "anomalyResistance", column = "anomaly_resistance"),
            @Result(property = "energyCapacity", column = "energy_capacity"),
            @Result(property = "energyRegenRate", column = "energy_regen_rate"),
            @Result(property = "talentBonus", column = "talent_bonus", typeHandler = com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "updateTime", column = "update_time")
    })
    AgentAttribute selectByAgentId(String agentId);
}